package com.wc.codeforces.思维.Equal_XOR;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/6/22 22:49
 * @description https://codeforces.com/problemset/problem/1944/B
 */
public class Main {
    /**
     * 思路：
     * 数组分为两段, 1 ~ n, n + 1 ~ n + n
     * 两边都有一个的数目是相同的
     * 剩下的就都剩下有两个了,并且数目相同, 右边有两个, 那左边就只有0了，那就可以通过一边就可以知道全貌了
     * 然后他要的答案又是偶数, 那就可以先把两个数的全挑了，不够的话，剩下的从1的里面各取一个，就完事了
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] nums = new int[N];
    static int[] zero = new int[N], one = new int[N], two = new int[N];
    static int n, k;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            k = sc.nextInt() * 2;
            Arrays.fill(nums, 1, n + 1, 0);
            for (int i = 1; i <= n; i++) {
                int x = sc.nextInt();
                nums[x]++;
            }
            int x = 0, y = 0, z = 0;
            for (int i = 1; i <= n; i++) sc.nextInt();
            for (int i = 1; i <= n; i++) {
                if (nums[i] == 0) zero[++x] = i;
                else if (nums[i] == 1) one[++y] = i;
                else two[++z] = i;
            }
            int id = 0;
            for (int i = 1; i <= z && id < k; i++, id += 2) {
                out.print(two[i] + " " + two[i] + " ");
            }
            for (int i = 1; i <= y && id < k; i++, id++) {
                out.print(one[i] + " ");
            }
            out.println();
            id = 0;
            for (int i = 1; i <= x && id < k; i++, id += 2) {
                out.print(zero[i] + " " + zero[i] + " ");
            }
            for (int i = 1; i <= y && id < k; i++, id++) {
                out.print(one[i] + " ");
            }
            out.println();
        }
        out.flush();
    }
}


class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}